class CreateUserCoupons < ActiveRecord::Migration[5.2]
  def change
    create_table :user_coupons do |t|
      t.integer :user_id, comment: "买家id"
      t.integer :coupon_id, comment: "优惠券id"
      t.integer :order_id, comment: "订单id"
      t.string :order_trade_no, comment: "订单号"
      t.decimal :order_original_amount, :decimal, :precision => 10, :scale => 2, :default => 0.0, comment: "原订单金额"
      t.decimal :order_final_amount, :decimal, :precision => 10, :scale => 2, :default => 0.0, comment: "抵扣优惠券之后的订单金额"
      t.decimal :coupon_amount, :decimal, :precision => 10, :scale => 2, :default => 0.0, comment: "优惠券的金额"
      t.integer :state, default: 0, comment: "优惠券状态"

      t.timestamps
    end
  end
end
